import { Behaviour, getGameObjectById, Transform, core, GameObject } from "./gameengine";
import { ColliderSystem } from "./rect/ColliderSystem";
import { RectCollider, RectColliderType } from "./rect/RectCollider";
import { fightingmouse} from "./data";
import{user}from "./user";


export class Applemeet extends Behaviour {
    ft: GameObject;
    private flag = false;


    // private speedX = 0;
    // private speedY = 0;


    protected onStart() {
    }

    protected onUpdate(advancedTime: number) {
        const colliderSystem = getGameObjectById("Scene").getScript(ColliderSystem);
        const collider = this.displayObject.getScript(RectCollider);
        const nextCollider = {
            left: collider.left + -4,
            right: collider.right + 4,
            top: collider.top + -4,
            bottom: collider.bottom + 4
        }
        const hitTestResult1 = colliderSystem.check(nextCollider, RectColliderType.MAINROLE);
        if(hitTestResult1)
        {
            user.apple+=1;
            this.displayObject.getScript(RectCollider).type=0;
            this.displayObject.parent.removeChild(this.displayObject);
        }

      
        

    }


}